package com.helen.wechat.controler;

import java.io.File;
import java.io.FileInputStream;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.helen.robot.HelenRobot;

/**
 * https://blog.csdn.net/qq_43001609/article/details/82818333
 * 
 * @author glowd
 * 
 * @date: 2018年11月4日
 *
 */

@RestController
public class HelloWorldController {

	@RequestMapping(value = "/helen", produces = MediaType.IMAGE_JPEG_VALUE)
	@ResponseBody
	public byte[] index() throws Exception {
		HelenRobot.newWechat();

		File file = new File(HelenRobot.path + "/QR.jpg");
		FileInputStream inputStream = new FileInputStream(file);
		byte[] bytes = new byte[inputStream.available()];
		inputStream.read(bytes, 0, inputStream.available());
		inputStream.close();
		return bytes;
	}
}